/*
 * $Id:   Broadcom SDK $
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 *
 * File:        phy5464cdiag.c
 * Purpose:     Software Cable Diags for BCM5461, BCM5464, BCM5482, and
 *              BCM5488
 *
 * Based on Broadcom PHY group Cable Diag Software release 3.0
 */

#if defined(INCLUDE_PHY_5464) || defined(INCLUDE_PHY_5482) || \
    defined(INCLUDE_PHY_54684_ESW) || defined(INCLUDE_PHY_54680) || \
    defined(INCLUDE_PHY_54880)

#include <sal/core/thread.h>
#include <soc/drv.h>
#include <soc/debug.h>
#include <soc/phy/phyctrl.h>
#include "phyreg.h"

typedef phy_ctrl_t*l1;typedef unsigned short int l2;typedef struct{int16 l3;
l1 l4;int16 l5;int16 l6;int16 l7[4];int16 l8[4];int16 l9;int16 l10[4];}l11;
typedef int32(*l12)(l11*l13);typedef struct{int16 l14;int16 l15;int16 l16;
int16 l17;int16 l18;int16 l19;}l20;typedef struct{int16 l21;int16 l22;int16
l23;int16 l24;}l25;extern void l26(l11*l13);extern int16 l27(int32 l28,int16
l29,int16 l30,int16 l31,int32*l32);extern int16 l33(l1 l34,int32*l35,int16*
l36);extern int16 l37(int32 l28,l1 l34);extern int16 l38(l1 l34,int16 l39,
int16 l40,int16 l41,int16 l42);extern int16 l43(l1 l34,int16 l44,int16*l45);
extern int16 l46(l1 l34,int16 l44,int16 l47);extern int16 l48(l1 l34,int l49,
int16*l50);extern int16 l51(l1 l34);extern int16 l52(l1 l34,int16 l53,int16
l54,int16 l55,int16*l45);extern int16 l56(l1 l34,int16 l53,int16 l54,int16 l55
,int16 l47);extern int16 l57(l1 l34,int16 l40,int l58);extern int16 l59(l1 l34
,int16 l40,int l58);extern int32 l60(l11*l13);extern int32 l61(l11*l13);
extern int32 l62(l11*l13);extern int32 l63(l11*l13);extern int32 l64(l11*l13)
;extern int32 l65(l11*l13);extern int32 l66(l11*l13);extern int16 l67(l11*l13
);extern int16 l68(l1 l34);extern int16 l69(l1 l34);extern int16 l70(int16 l71
,int16 l72,l1 l34,int16 l73,int16 l7[],int16 l8[],int32 l74[4],int16 l75[4+1]
,int16 l76[4+1][4+1],int16 l77[4+1][4+1],int16 l78[4],int32 l79[4],int16 l80[
4]);extern int16 l81(int16 l71,l1 l34,int16 l73,int16 l7[],int16 l8[],int32
l74[4],int16*l82,int16 l75[4+1],int16 l76[4+1][4+1],int16 l77[4+1][4+1]);
extern char*l83;int16 l69(l1 l34){int l84 = 0;int16 l85 = 0;l84 = 0x0000;if(!
(l34->phy_oui == 0x000af7||l34->phy_model == 0x3e)){return 0x0000;}sal_usleep
(1000*(1));l84|= l46(l34,0x17,(int16)0x0f76);l84|= l46(l34,0x15,(int16)0x0040
);l84|= l46(l34,0x17,(int16)0x0f75);l84|= l46(l34,0x15,(int16)0x003d);l84|= 
l43(l34,0x00,&l85);l85|= 0x1200;l84|= l46(l34,0x0,l85);return l84;}int16 l43(
l1 l34,int16 l44,int16*l45){int l86;uint16 l87;l86 = READ_PHY_REG(l34->unit,
l34,l44,&l87);if(l86<0){return 0x0001;}else{*l45 = l87;return 0x0000;}}int16
l46(l1 l34,int16 l44,int16 l47){int l86;uint16 l87;l87 = l47;l86 = 
WRITE_PHY_REG(l34->unit,l34,l44,l87);if(l86<0){return 0x0001;}else{return
0x0000;}}int16 l48(l1 l34,int l49,int16*l50){int16 l84,l88;l84 = 0x0000;l84|= 
l46(l34,0x18,0x7);l84|= l43(l34,0x18,l50);l84|= l46(l34,0x18,(*l50|0x0800)&((
int16)0xFFF8));if(l49!=0){l84|= l43(l34,0x18,&l88);if((l88&0x0800) == 0)l84|= 
0x0008;}return l84;}int16 l51(l1 l34){int16 l84,l89;l84 = 0x0000;l84|= l46(
l34,0x18,0x7);l84|= l43(l34,0x18,&l89);if((l89&0x0800) == 0)l84|= 0x0004;
return l84;}int16 l90(l1 l34,int16 l53,int16 l55,int16*l45){int16 l84;int16
l91;l84 = 0x0000;l91 = ((l53&0x0003)<<13)|(l55&0x00FF);l84|= l46(l34,0x17,l91
);l84|= l43(l34,0x15,l45);return l84;}int16 l52(l1 l34,int16 l53,int16 l54,
int16 l55,int16*l45){int16 l84;int16 l91;l84 = 0x0000;l91 = ((l53&0x0007)<<13
)|((l54&0x001F)<<8)|(l55&0x00FF);l84|= l46(l34,0x17,l91);l84|= l43(l34,0x15,
l45);return l84;}int16 l56(l1 l34,int16 l53,int16 l54,int16 l55,int16 l47){
int16 l84;int16 l91;l84 = 0x0000;l91 = ((l53&0x0007)<<13)|((l54&0x001F)<<8)|(
l55&0x00FF);l84|= l46(l34,0x17,l91);l84|= l46(l34,0x15,l47);return l84;}int16
l57(l1 l34,int16 l40,int l58){int16 l84;l84 = 0x0000;l84|= l46(l34,0x17,
0x0FFF);if(l40 == -1)l84|= l46(l34,0x15,(l58?0x2000:0x20F0));else if(l58 == 1
)l84|= l46(l34,0x15,0x20F0^((0x0010)<<l40));else l84|= 0x0002;return l84;}
int16 l59(l1 l34,int16 l40,int l58){int16 l84;l84 = 0x0000;if(l40 == -1){l84
|= l46(l34,0x17,(int16)0x8005);l84|= l46(l34,0x15,(l58?0x2000:0x3000));}else
if(l58 == 1){l84|= l46(l34,0x17,((l40&0x3)<<13)|0x0005);l84|= l46(l34,0x15,
0x2000);}else{l84|= 0x0002;}return l84;}int32 l62(l11*l13){int16 l92,l93;l1 l4
;int16 l84;l84 = 0x0000;l4 = l13->l4;l84|= l43(l4,0x1A,&l92);l84|= l43(l4,
0x11,&l93);sal_usleep(1000*(4000));l84|= l43(l4,0x11,&l93);l93&= 0x0FFE;l84|= 
l43(l4,0x1A,&l92);if(l92&6){l93 = 0;}if(l93 == 0x0F00){l84|= l43(l4,0x19,&l92
);l13->l10[0] = (l92>>8)&0x7;return l84;}else{l13->l10[0] = 0;return 0x0004;}
}int32 l63(l11*l13){int16 l92,l93;l1 l4;int16 l84;l84 = 0x0000;l4 = l13->l4;
l84|= l43(l4,0x1A,&l92);l84|= l43(l4,0x11,&l93);sal_usleep(1000*(4000));l84|= 
l43(l4,0x11,&l93);l93&= 0x0FFE;l84|= l43(l4,0x1A,&l92);if(l92&6){l93 = 0;}l13
->l10[0] = (l93>>8)&0x000F;return l84;}int32 l64(l11*l13){int16 l94,l95;int16
l96,l97,l98;int16 l84;int16 l99;l84 = 0x0000;l84|= l43(l13->l4,0x11,&l99);l99
&= 0x2000;l84|= l46(l13->l4,0x18,7);l84|= l43(l13->l4,0x18,&l94);l94|= 0x0800
;l84|= l46(l13->l4,0x18,l94);for(l98=0;l98<4;l98++){l84|= l90(l13->l4,l98,
0x05,&l94);if(l94&0x0020){l96 = (l94&0x01);l97 = ((l94>>1)&0x01);l95 = (l94>>
3)&0x03;switch(l95){case 0:if(l99)l13->l10[l98] = (0x0A);else l13->l10[l98] = 
(0x0B);break;case 1:if(l99)l13->l10[l98] = (0x0B);else l13->l10[l98] = (0x0A)
;break;case 2:if(l99){if(!l97)l13->l10[l98] = (0x0C);else l13->l10[l98] = (
0x0D);}else{if(l97)l13->l10[l98] = (0x0C);else l13->l10[l98] = (0x0D);}break;
case 3:if(l99){if(!l97)l13->l10[l98] = (0x0D);else l13->l10[l98] = (0x0C);}
else{if(l97)l13->l10[l98] = (0x0D);else l13->l10[l98] = (0x0C);}break;default
:break;}}else{l13->l10[l98] = -1;}}return l84;}int32 l65(l11*l13){int16 l94;
int16 l98;int16 l84;int16 l99;l84 = 0x0000;l84|= l43(l13->l4,0x11,&l99);l99&= 
0x2000;l84|= l46(l13->l4,0x18,7);l84|= l43(l13->l4,0x18,&l94);l94|= 0x800;l84
|= l46(l13->l4,0x18,l94);for(l98=0;l98<4;l98++){l84|= l90(l13->l4,l98,0x05,&
l94);if(l94&0x0020)l13->l10[l98] = ((l94>>2)&0x01);else l13->l10[l98] = -1;}
if(l99 == 0){l94 = l13->l10[0];l13->l10[0] = l13->l10[1];l13->l10[1] = l94;
l94 = l13->l10[2];l13->l10[2] = l13->l10[3];l13->l10[3] = l94;}return l84;}
int32 l66(l11*l13){int16 l94;int16 l98;int16 l84;l84 = 0x0000;l84|= l46(l13->
l4,0x18,7);l84|= l43(l13->l4,0x18,&l94);l94|= 0x0800;l84|= l46(l13->l4,0x18,
l94);for(l98=0;l98<4;l98++){l84|= l90(l13->l4,l98,0x05,&l94);if(l94&0x0020)
l13->l10[l98] =((l94>>6)&0x0F);else l13->l10[l98] = -1;}return l84;}static
int16 l100(l1 l34,int16 l73){int16 l84;l84 = 0x0000;l84|= l46(l34,0x0,(int16)
0x8000);sal_usleep(1000*(1));l84|= l69(l34);l84|= l46(l34,0x00,0x0040);l84|= 
l46(l34,0x1e,0x0080);l84|= l46(l34,0x18,0x0C00);l84|= l46(l34,0x17,0x0F2B);
l84|= l46(l34,0x15,0x0001);l84|= l46(l34,0x17,0x0F2A);l84|= l46(l34,0x18,
0x0282);l84|= l46(l34,0x15,((int16)0xEEAB));l84|= l46(l34,0x17,0x0F27);l84|= 
l46(l34,0x15,((int16)0xD2ED));l84|= l46(l34,0x17,0x0F28);l84|= l46(l34,0x15,
0x2C05);l84|= l46(l34,0x17,0x0F29);l84|= l46(l34,0x15,0x0010);if(l73 == 0){
l84|= l46(l34,0x17,0x0F1D);l84|= l46(l34,0x15,((int16)0x1E1E));l84|= l46(l34,
0x17,0x0F1E);l84|= l46(l34,0x15,((int16)0x231F));l84|= l46(l34,0x17,0x0F1F);
l84|= l46(l34,0x15,((int16)0x131A));}return l84;}static int16 l101(l1 l34,
int16 l102,int16 l103,int16 l73){int16 l84;l84 = 0x0000;if(l102 == 0){if(l73
== 0){l84|= l46(l34,0x17,0x0F14);l84|= l46(l34,0x15,((int16)0x2E01));l84|= 
l46(l34,0x17,0x0F15);l84|= l46(l34,0x15,((int16)0x49AC));l84|= l46(l34,0x17,
0x0F16);l84|= l46(l34,0x15,((int16)0x57BB));l84|= l46(l34,0x17,0x0F17);l84|= 
l46(l34,0x15,((int16)0x27A6));l84|= l46(l34,0x17,0x0F18);l84|= l46(l34,0x15,(
(int16)0x0785));l84|= l46(l34,0x17,0x0F19);l84|= l46(l34,0x15,((int16)0x0025)
);l84|= l46(l34,0x17,0x0F2C);l84|= l46(l34,0x15,((int16)0x0025));}}else{l84|= 
l46(l34,0x17,0x0F14);l84|= l46(l34,0x15,((int16)0x0100));l84|= l46(l34,0x17,
0x0F15);l84|= l46(l34,0x15,((int16)0x1DBC));l84|= l46(l34,0x17,0x0F16);l84|= 
l46(l34,0x15,((int16)0x1191));l84|= l46(l34,0x17,0x0F17);l84|= l46(l34,0x15,(
(int16)0x08B8));l84|= l46(l34,0x17,0x0F18);l84|= l46(l34,0x15,((int16)0x01E8)
);l84|= l46(l34,0x17,0x0F19);l84|= l46(l34,0x15,((int16)0x0007));l84|= l46(
l34,0x17,0x0F2C);l84|= l46(l34,0x09,(int16)0x9800);l84|= l46(l34,0x15,((int16
)0x0007));}l84|= l46(l34,0x17,0x0F10);l84|= l46(l34,0x15,l103);return l84;}
static int16 l104(l1 l34,int16 l103,int16 l40,int16 l75[],int16 l76[4+1][4+1]
,int16 l77[4+1][4+1],int32 l105[4+1][4+1]){int16 l84,l106,l107,l108,l109,l110
;int16 l111;l84 = 0x0000;if(l40>= 0){l84|= l59(l34,-1,0);l84|= l59(l34,l40,1)
;}l84|= l46(l34,0x17,0x0F10);l84|= l46(l34,0x15,l103|0x0002);l110 = 0;for(
l111=0;l111<3000;l111++){l84|= l43(l34,0x15,&l106);if((l106&0x0200)!= 0){l110
= 1;break;}}l84|= l46(l34,0x17,0x0F11);l84|= l43(l34,0x15,&l107);assert((l40+
1)>= 0);if(l110 == 0){l75[l40+1] = 1;l84|= 0x0001;}else if((l107&0xF000)!= 0)
{l75[l40+1] = 1;l84|= 0x0002;}else{l75[l40+1] = 0;}for(l111=0;l111<4;l111++)
l76[l111][l40+1] = (l107>>(l111*2))&0x0003;if(l40<= 0){l84|= l46(l34,0x17,
0x0F12);l84|= l43(l34,0x15,&l108);l77[0][l40+1] = l75[l40+1]?-99:(l108&0x00FF
);l77[1][l40+1] = l75[l40+1]?-99:((l108&0xFF00)>>8);}l84|= l46(l34,0x17,
0x0F13);l84|= l43(l34,0x15,&l109);l77[2][l40+1] = l75[l40+1]?-99:(l109&0x00FF
);l77[3][l40+1] = l75[l40+1]?-99:((l109&0xFF00)>>8);return l84;}static int16
l112(int16 l113[4],int16 l80[4]){int16 l40,l114,l115,l116[4][4],l117,l118;
int16 l119,l120,l121,l122,l123;int32 l124,l125,l126,l127,l128,l129,l130;int32
l131,l132,l133,l134;l120 = -1;l121 = -1;l128 = 32766;l122 = -1;l123 = -1;l129
= 32767;l115 = 0;for(l40=0;l40<4;l40++){for(l114=l40+1;l114<4;l114++){l116[
l40][l114] = 0;l116[l114][l40] = 0;if((l80[l114] == 0)||(l80[l40] == 0))
continue;l127 = (((l113[l114])<(l113[l40]))?(l113[l114]):(l113[l40]));l124 = 
(((((int32)300))>((l127+((int32)14)/2)/((int32)14)))?(((int32)300)):((l127+((
int32)14)/2)/((int32)14)));l130 = (((l113[l114]-l113[l40])>= 0)?(l113[l114]-
l113[l40]):-(l113[l114]-l113[l40]));if(l130<= l124){l116[l40][l114] = 1;l116[
l114][l40] = 1;l115++;if(l130<l128){l122 = l120;l123 = l121;l129 = l128;l120 = 
l40;l121 = l114;l128 = l130;}else if(l130<l129){l122 = l40;l123 = l114;l129 = 
l130;}}}}if(l115 == (4*(4-1)/2)){return 4;}else{l118 = -1;l133 = 100000;for(
l117=0;l117<4;l117++){l119 = 1;l134 = 0;for(l40=0;l40<4;l40++){if(l117 == l40
)continue;for(l114=l40+1;l114<4;l114++){if(l117 == l114)continue;l134+= (((
l113[l114]-l113[l40])>= 0)?(l113[l114]-l113[l40]):-(l113[l114]-l113[l40]));if
(l116[l114][l40] == 0)l119 = 0;}}if((l119 == 1)&&(l134<l133)){l118 = l117;
l133 = l134;}}if(l118!= -1){l126 = 0;for(l114=0;l114<4;l114++){if(l118 == 
l114)continue;l126+= l113[l114];}l131 = l126/(4-1);l125 = (((((int32)600))>((
l131+((int32)10)/2)/((int32)10)))?(((int32)600)):((l131+((int32)10)/2)/((
int32)10)));if(l113[l118]<= l131){l132 = ((((int32)l113[l118])>(l131-l125))?(
(int32)l113[l118]):(l131-l125));}else{l132 = ((((int32)l113[l118])<(l131+l125
))?((int32)l113[l118]):(l131+l125));}l113[l118] = (int16)((l131+l132+1)/2);
return(4-1);}else if(l120!= -1){if((l122!= -1)&&(l122!= l120)&&(l122!= l121)
&&(l123!= l120)&&(l123!= l121)&&((((l129-l128)>= 0)?(l129-l128):-(l129-l128))
<= 200)){l126 = 0;for(l114=0;l114<4;l114++){l126+= l113[l114];}for(l114=0;
l114<4;l114++){l113[l114] = (int16)(l126/4);}return 1;}else{l131 = (l113[l120
]+l113[l121]+1)/2;l125 = (((((int32)600))>((l131+((int32)10)/2)/((int32)10)))
?(((int32)600)):((l131+((int32)10)/2)/((int32)10)));for(l114=0;l114<4;l114++)
{if((l114 == l120)||(l114 == l121))continue;if(l113[l114]<= l131){l132 = ((((
(int32)l113[l114]))>(l131-l125))?(((int32)l113[l114])):(l131-l125));}else{
l132 = (((((int32)l113[l114]))<(l131+l125))?(((int32)l113[l114])):(l131+l125)
);}l113[l114] = (int16)((l131+l132+1)/2);}return 2;}}else{return 0;}}return-1
;}static int16 l135(int16 l71,int16 l76[4+1][4+1],int16 l77[4+1][4+1],int32
l105[4+1][4+1],int16 l7[],int16 l8[],int32 l74[4],int16*l82){int16 l84;int16
l136,l137,l40,l114,l138;int16 l113[4],l80[4];l84 = 0x0000;*l82 = 0;for(l114=0
;l114<4;l114++){l8[l114] = (int16)0x7FFF;l138 = 0;for(l136=0;l136<4;l136++){
if(l136 == l114)continue;l40 = (((l114)<(l136))?(l114):(l136));l137 = (((l114
)>(l136))?(l114):(l136));if((l76[l137][l40+1] == 1)||(l76[l137][l40+1] == 2))
{l7[l114] = 0x0001;l8[l114] = (int16)(((((int32)l8[l114]))<(((int32)l77[l137]
[l40+1]*100)))?(((int32)l8[l114])):(((int32)l77[l137][l40+1]*100)));if(l8[
l114]>l77[l137][l40+1]*100)l74[l114] = l105[l137][l40+1];*l82|= (0x1<<(l136*4
+l114));l138 = 1;}}if(l138==0){switch(l76[l114][0]){case 0:l7[l114] = 0x0000;
break;case 1:l7[l114] = 0x0002;break;case 2:l7[l114] = 0x0004;break;case 3:l7
[l114] = 0x0001;l84|= 0x0004;break;default:l7[l114] = -99;l84|= 0x0010;break;
}l8[l114] = l77[l114][0]*100;l74[l114] = l105[l114][0];}}for(l114=0;l114<4;
l114++){l113[l114] = l8[l114];if(l7[l114] == 0x0000)l80[l114] = 1;else l80[
l114] = 0;}if(l71!= 0){(void)l112(l113,l80);for(l114=0;l114<4;l114++){if(l7[
l114] == 0x0000)l8[l114] = l113[l114];}}return l84;}int16 l81(int16 l71,l1 l34
,int16 l73,int16 l7[],int16 l8[],int32 l74[4],int16*l82,int16 l75[4+1],int16
l76[4+1][4+1],int16 l77[4+1][4+1]){int16 l40,l84;int16 l103;int32 l105[4+1][4
+1];l103 = 0;l84 = 0x0000;l84|= l100(l34,l73);for(l40=-1;l40<(4-1);l40++){if(
l40 == -1){l103 = 0x0089;l84|= l101(l34,0,l103,l73);}else if(l40 == 0){l103 = 
0x0009;/* coverity[negative_returns] */ l84|= l101(l34,1,l103,l73);}l84|= l104(l34,l103,l40,l75,l76,l77,l105);
}l84|= l135(l71,l76,l77,l105,l7,l8,l74,l82);l84|= l46(l34,0x0,(int16)0x8000);
sal_usleep(1000*(1));l84|= l69(l34);return l84;}static int32 l139(uint16 l140
,int16 l141){const int32 l142 = 0x16A0A;const int32 l143 = 0xB172;const int32
l144[10] = {65536/1,65536/2,65536/3,65536/4,65536/5,65536/6,65536/7,65536/8,
65536/9,65536/10};int32 l145,l146,l147,l148;int16 l149,l111;if(l141>10)return
(0x80000000);l145 = (int32)l140;l149 = 15;for(l111=0;l111<16;l111++){if(l145&
0x8000)break;l145<<= 1;l149--;}if(l149<0)return(0x80000000);l145 = (int32)
l140;if((l145<<(16-l149))>l142)l149++;l146 = (int32)l140;l146 = (((int32)1)<<
16)-(l146<<(16-l149));l147 = l146;l148 = l147;for(l111=2;l111<=l141;l111++){
l147 = ((l147>>1)*(l146>>1))>>14;l148+= (((l147>>1)*(l144[l111-1]>>1))>>14);}
return(l143*l149-l148);}static int16 l150(int32 l28,l1 l34,int16 l114,int16
l78[],int32 l79[4]){const int32 l151 = 0x003E;const int32 l144 = 0x08B0;const
int16 l152 = 8;int16 l84,l41,l42,l111;int32 l153,l154,l155,l156;l84 = 0x0000;
l153 = 0;l154 = 0;for(l111=0;l111<l152;l111++){l84|= l46(l34,0x17,(l114<<13))
;l84|= l43(l34,0x15,&l41);l153+= (l41&0x007F);l84|= l46(l34,0x17,(l114<<13)|
0x0100);l84|= l43(l34,0x15,&l42);l154+= l42;}l155 = ((l153+4)>>3)*l151;l156 = 
(((l144>>1)*(l139((uint16)((l154+4)>>3),6)>>1))>>14)+l155;l78[l114] = (int16)
((((0)>(((((l156*l156)>>16)*((int32)-808))>>8)+((l156*((int32)1501))>>8)+((
int32)-98092)))?(0):(((((l156*l156)>>16)*((int32)-808))>>8)+((l156*((int32)
1501))>>8)+((int32)-98092))));l79[l114] = l156;return l84;}static int16 l157(
int16 l76[4+1][4+1],int16 l77[4+1][4+1],int16 l78[4],int16 l80[4]){int16 l84,
l114;int32 l158,l159;l84 = 0x0000;for(l114=0;l114<4;l114++){if(l76[l114][0]!= 
0)l84|= 0x0008;l158 = (((((int32)600))>((l78[3]+((int32)3)/2)/((int32)3)))?((
(int32)600)):((l78[3]+((int32)3)/2)/((int32)3)));l159 = (((((int32)600))>((
l78[3]+((int32)4)/2)/((int32)4)))?(((int32)600)):((l78[3]+((int32)4)/2)/((
int32)4)));if(((l77[l114][0]*100)<= (l78[3]+l158))&&((l77[l114][0]*100)>= (
l78[3]-l159))){l80[l114] = 1;}else{l80[l114] = 0;}}return l84;}int16 l70(
int16 l71,int16 l72,l1 l34,int16 l73,int16 l7[],int16 l8[],int32 l74[4],int16
l75[4+1],int16 l76[4+1][4+1],int16 l77[4+1][4+1],int16 l78[4],int32 l79[4],
int16 l80[4]){int16 l114,l84;int16 l89;int16 l103;int32 l105[4+1][4+1];l84 = 
0x0000;l84|= l46(l34,0x18,0x7);l84|= l43(l34,0x18,&l89);l84|= l46(l34,0x18,(
l89|0x0800)&((int16)0xFFF8));if(l73 == 0){l84|= l46(l34,0x17,0x0F20);l84|= 
l46(l34,0x15,((int16)0x1210));l84|= l46(l34,0x17,0x0F21);l84|= l46(l34,0x15,(
(int16)0x1B20));}l84|= l46(l34,0x17,0x0F10);l103 = 0x0005;l84|= l46(l34,0x15,
l103);/* coverity[negative_returns] */ l84|= l104(l34,l103,-1,l75,l76,l77,l105);for(l114=0;l114<4;l114++){l7[
l114] = 0x0010;l8[l114] = l77[l114][0]*100;l74[l114] = l105[l114][0];}if(l71
!= 0){if(l72!= 0){l84|= l150(0x00000003,l34,3,l78,l79);l84|= l157(l76,l77,l78
,l80);}else{for(l114=0;l114<4;l114++)l80[l114] = 1;}if(l112(l8,l80)<= 0){if(
l72!= 0){for(l114=0;l114<4;l114++){l8[l114] = l78[3];}}}}l84|= l46(l34,0x17,
0x0F10);l84|= l46(l34,0x15,0x0080);l84|= l46(l34,0x18,l89&0xFFF8);return l84;
}static const int16 l160 = (800000/4/(3*60+4*60));static const int16 l161 = (
15000/4/(3*60+4*60));static const int16 l162[192] = {22743,22308,21880,21461,
21050,20647,20251,19864,19483,19110,18744,18385,18033,17687,17348,17016,16690
,16370,16057,15749,15447,15152,14861,14577,14297,14023,13755,13491,13233,
12979,12731,12487,12248,12013,11783,11557,11336,11119,10906,10697,10492,10291
,10094,9900,9711,9525,9342,9163,8988,8816,8647,8481,8319,8159,8003,7850,7699,
7552,7407,7265,7126,6990,6856,6724,6596,6469,6345,6224,6105,5988,5873,5760,
5650,5542,5436,5332,5229,5129,5031,4935,4840,4747,4656,4567,4480,4394,4310,
4227,4146,4067,3989,3913,3838,3764,3692,3621,3552,3484,3417,3352,3287,3224,
3163,3102,3043,2984,2927,2871,2816,2762,2709,2657,2606,2557,2508,2460,2412,
2366,2321,2276,2233,2190,2148,2107,2067,2027,1988,1950,1913,1876,1840,1805,
1770,1736,1703,1671,1639,1607,1576,1546,1517,1487,1459,1431,1404,1377,1350,
1325,1299,1274,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,
1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,
1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,};
static const int16 l163[192] = {22743,22308,21880,21461,21050,20647,20251,
19864,19483,19110,18744,18385,18033,17687,17348,17016,16690,16370,16057,15749
,15447,15152,14861,14577,14297,14023,13755,13491,13233,12979,12731,12487,
12248,12013,11783,11557,11336,11119,10906,10697,10492,10291,10094,9900,9711,
9525,9342,9163,8988,8816,8647,8481,8319,8159,8003,7850,7699,7552,7407,7265,
7126,6990,6856,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,
3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,3428,
3428,3428,3428,3428,3428,3428,3428,3428,3417,3352,3287,3224,3163,3102,3043,
2984,2927,2871,2816,2762,2709,2657,2606,2557,2508,2460,2412,2366,2321,2276,
2233,2190,2148,2107,2067,2027,1988,1950,1913,1876,1840,1805,1770,1736,1703,
1671,1639,1607,1576,1546,1517,1487,1459,1431,1404,1377,1350,1325,1299,1274,
1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,
1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,
1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,1259,};static const
int16 l164[192] = {1743,1716,1688,1662,1635,1609,1584,1558,1534,1509,1485,
1462,1438,1416,1393,1371,1349,1328,1307,1286,1265,1245,1225,1206,1187,1168,
1149,1131,1113,1095,1078,1061,1044,1027,1011,995,979,964,948,933,918,904,889,
875,861,848,834,821,808,795,782,770,758,746,734,722,711,699,688,677,666,656,
645,635,625,615,605,596,586,577,568,559,550,541,533,524,516,508,499,492,484,
476,468,461,454,446,439,432,426,419,412,406,399,393,387,380,374,368,363,357,
351,345,340,335,329,324,319,314,309,304,299,294,290,285,281,276,272,267,263,
259,255,251,247,243,239,235,231,228,224,221,217,214,210,207,204,200,197,194,
191,188,185,182,179,176,173,171,168,165,163,160,158,158,158,158,158,158,158,
158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,
158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,};static const
int16 l165[192] = {116,116,115,115,115,114,114,114,113,113,112,112,112,111,
111,111,110,110,110,109,109,108,108,108,107,107,107,106,106,106,105,105,105,
104,104,104,103,103,103,102,102,101,101,101,100,100,100,99,99,99,99,98,98,98,
97,97,97,96,96,96,95,95,95,94,94,94,93,93,93,92,92,92,92,91,91,91,90,90,90,89
,89,89,89,88,88,88,87,87,87,87,86,86,86,85,85,85,85,84,84,84,83,83,83,83,82,
82,82,82,81,81,81,80,80,80,80,79,79,79,79,78,78,78,78,77,77,77,77,76,76,76,76
,75,75,75,75,74,74,74,74,73,73,73,73,72,72,72,72,71,71,71,71,71,71,71,71,71,
71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71
,71,71,71,71,71,71,71,71,71,71,};static const int32 l166 = 5;static int16 l167
,l168;static int16 l169,l170;static int32 l171,l172;static int16 l173,l174;
static int32 l175,l176;int16 l27(int32 l28,int16 l29,int16 l30,int16 l31,
int32*l32){int16 l84,l177;int32 l178;l84 = 0x0000;switch(l28){case 0x00000001
:if(l29<64)l177 = 19;else l177 = 16;break;case 0x00000002:if(l29<64)l177 = 17
;else l177 = 14;break;case 0x00000003:case 0x00000004:case 0x00000005:if(l29<
32)l177 = 17;else if(l29<64)l177 = 16;else if(l29<96)l177 = 15;else if(l29<
128)l177 = 14;else l177 = 13;break;default:l177 = -1;l84|= 0x0008;break;}
switch(l177){case 19:l178 = ((int32)l30)&0x0000000F;if((l30&0x0008)!= 0)*l32 = 
0xFFFC0000|(l178<<15)|(((int32)l31)&0x00007FFF);else*l32 = (l178<<15)|(((
int32)l31)&0x00007FFF);break;case 17:l178 = ((int32)l30)&0x00000003;if((l30&
0x0002)!= 0)*l32 = 0xFFFF0000|(l178<<15)|(((int32)l31)&0x00007FFF);else*l32 = 
(l178<<15)|(((int32)l31)&0x00007FFF);break;case 16:l178 = ((int32)l30)&
0x00000001;if((l30&0x0001)!= 0)*l32 = 0xFFFF8000|(l178<<15)|(((int32)l31)&
0x00007FFF);else*l32 = (l178<<15)|(((int32)l31)&0x00007FFF);break;case 15:if(
(l31&0x4000)!= 0)*l32 = 0xFFFFC000|((int32)l31);else*l32 = 0x00007FFF&((int32
)l31);break;case 14:if((l31&0x2000)!= 0)*l32 = 0xFFFFE000|((int32)l31);else*
l32 = 0x00003FFF&((int32)l31);break;case 13:if((l31&0x1000)!= 0)*l32 = 
0xFFFFF000|((int32)l31);else*l32 = 0x00001FFF&((int32)l31);break;default:*l32
= -1;break;}return l84;}static int16 l179(int32 l28,l1 l34,int16 l114,int32*
l180,int16*l181){int16 l111;int32 l182,l183;int16 l84;int16 l30,l31,l184;
int16 l185;l84 = 0x0000;l183 = 0;l84|= l51(l34);l84|= l46(l34,0x17,(l114<<13)
|0x0300);l84|= l43(l34,0x16,&l184);l84|= l46(l34,0x16,(l184&0xFBFF)|0x0080);
l84|= l43(l34,0x16,&l185);l84|= ((l185&0x1800)?0x0001:0);l84|= l46(l34,0x16,(
l184&0xFBFF)|0x0800);l84|= l43(l34,0x16,&l185);l84|= ((l185&0x1800)?0x0001:0)
;for(l111=0;l111<192;l111++){l84|= l43(l34,0x15,&l31);l84|= l43(l34,0x15,&l30
);l84|= l27(l28,l111,l30,l31,&l182);l183+= (((l182)>= 0)?(l182):-(l182));*
l180+= l182;l180+= 2;}if(l183 == 0)*l181 = 0;else*l181 = 1;return l84;}int16
l33(l1 l34,int32*l35,int16*l36){int16 l84,l186,l187;int32 l188;l84 = 0x0000;
l84|= l43(l34,0x02,&l186);l84|= l43(l34,0x03,&l187);l188 = (((int32)l186)<<16
)|(((int32)l187)&0x0000FFF0);switch(l188){case 0x002060A0:*l35 = 0x00000001;
break;case 0x002060C0:case 0x002060D0:case 0x002060B0:case 0x002063B0:case
0x002061A0:case 0x00206180:case 0x00206100:case 0x00206340:case 0x00206350:
case 0x00206150:case 0x00206360:case 0x0143bcd0:case 0x0143bcf0:*l35 = 
0x00000002;break;case 0x0143BC80:*l35 = 0x00000003;break;case 0x0143BC90:case
0x0143BCA0:case 0x0143BCB0:*l35 = 0x00000004;break;case 0x0143BE80:case
0x0143BE90:case 0x0143BEA0:case 0x0143BEB0:case 0x0143BF80:case 0x0143BFE0:
case 0x03625F20:default:*l35 = 0x00000005;break;}*l36 = 0;return l84;}static
int16 l189(l1 l34,int16 l190,int16 l191){int16 l84,l192;l84 = 0x0000;l84|= 
l46(l34,0x17,0x000B);l190&= 0x003F;l191&= 0x003F;if(l190<= l191){for(l192 = 
l190;l192<=l191;l192++){l84|= l46(l34,0x15,((l192<<6)|0x8000)&0xFFFF);}}else{
for(l192 = l190;l192>=l191;l192--){l84|= l46(l34,0x15,((l192<<6)|0x8000)&
0xFFFF);}}return l84;}int16 l37(int32 l28,l1 l34){int16 l84,l89;l84 = 0x0000;
l84|= l46(l34,0x00,(int16)0x8000);l84|= l69(l34);l84|= l48(l34,1,&l89);if((
l28!= 0x00000001)&&(l28!= 0x00000002)){l84|= l46(l34,0x18,(int16)0x0282);l84
|= l46(l34,0x17,0x0F2B);l84|= l46(l34,0x15,0x0040);}l84|= l46(l34,0x00,0x1200
);l84|= l46(l34,0x00,(int16)0x0040);l84|= l59(l34,-1,0);l84|= l46(l34,0x17,(
int16)0x001A);l84|= l46(l34,0x15,(int16)0x8000);l84|= l46(l34,0x1E,0x0080);
l84|= l46(l34,0x17,0x001F);l84|= l46(l34,0x15,0x0480);l84|= l46(l34,0x17,(
int16)0x8004);l84|= l46(l34,0x15,0x0040);l84|= l46(l34,0x17,(int16)0x800C);
l84|= l46(l34,0x15,0x0040);l84|= l46(l34,0x17,(int16)0x8100);l84|= l46(l34,
0x16,0x0002);l84|= l46(l34,0x17,(int16)0x9000);l84|= l46(l34,0x16,(int16)
0x0004);l84|= l46(l34,0x17,(int16)0x8300);l84|= l46(l34,0x16,(int16)0x0000);
return l84;}int16 l38(l1 l34,int16 l39,int16 l40,int16 l41,int16 l42){int16
l84;l84 = 0x0000;l84|= l46(l34,0x17,(int16)0x8000);l84|= l46(l34,0x15,l41);
l84|= l46(l34,0x17,(int16)0x8100);l84|= l46(l34,0x15,l42);l84|= l46(l34,0x17,
0x000B);l84|= l46(l34,0x15,(int16)0x8000);if(l39 == 0){l84|= l59(l34,-1,0);
l84|= l59(l34,l40,1);l84|= l46(l34,0x09,(int16)0x9000);l84|= l46(l34,0x09,(
int16)0x9800);}else if(l39 == 1){l84|= l59(l34,-1,1);l84|= l46(l34,0x09,(
int16)0x9000);l84|= l46(l34,0x09,(int16)0x9800);}else{l84|= l59(l34,-1,0);l84
|= l46(l34,0x09,(int16)0x9000);l84|= l46(l34,0x09,(int16)0x9800);}if(l39>= 0)
sal_usleep(1000*(20));return l84;}int16 l68(l1 l34){int16 l84;int16 l193,l194
;l84 = 0x0000;l84|= l43(l34,0x1A,&l194);l84|= l43(l34,0x11,&l193);l84|= l43(
l34,0x11,&l193);l193&= 0x0FFE;l84|= l43(l34,0x1A,&l194);if((l194&0x6)||(l84!= 
0x0000))l193 = 0;return((l193 == 0x0F00)?1:0);}int16 l195(int16 l196,int16 l5
,l1 l34,int16 l197[],int16 l198[]){int16 l84,l53;int16 l89,l199;int16 l200,
l201;l84 = 0x0000;l200 = l5&0x0001;l201 = (l5&0x0002)>>1;for(l53=0;l53<4;l53
++){l197[l53] = l53;l198[l53] = l53;}if(l196){l84|= l48(l34,1,&l89);l84|= l46
(l34,0x17,((0x0&0x0003)<<13)|(0x05&0x00FF));l84|= l43(l34,0x15,&l199);if((
l199&0x20) == 0)l84|= 0x2000;l200^= l199&0x0001;l201^= ((l199&0x0002)>>1);}
for(l53=0;l53<4;l53++){if((l53 == 0)&&(l200!= 0)){l197[1] = 0;l198[0] = 1;}
else if((l53 == 1)&&(l200!= 0)){l197[0] = 1;l198[1] = 0;}else if((l53 == 2)&&
(l201!= 0)){l197[3] = 2;l198[2] = 3;}else if((l53 == 3)&&(l201!= 0)){l197[2] = 
3;l198[3] = 2;}}return l84;}static void l202(int32*l180){int16 l111;int32 l148
,l203,*l204;l148 = 0;l204 = l180+2*(192-20);for(l111=0;l111<2*20;l111+=2)l148
+= *(l204+l111);l203 = ((l148<<8)/20)>>8;for(l111=0;l111<2*192;l111+=2)*(l180
+l111)-= l203;return;}static int32 l205(int16 l196,int32 l206[],int16 l114,
int16 l207,int32 l208,int32 l209,int16 l210,int16 l211,int16 l212){int32 l148
,*l204;l148 = 0;for(l204=l206+(((l207-l210)>(0))?(l207-l210):(0))+l114*2*192;
l204<=(l206+(((l207+l211)<(2*192))?(l207+l211):(2*192))+l114*2*192);l204++){
l148+= (l196?(*l204):(*l204));}if((l207>= l212)&&(((((l148)>= 0)?(l148):-(
l148))*l209)<l208))return-1;else return(((l148)>= 0)?(l148):-(l148));}static
void l213(int32 l206[],l20 l214[2*2][4],int32*l215,int16 l216[],int16 l217[],
l25 l218[]){return;}static void l219(l20 l214[2*2][4]){int16 l220,l114;for(
l220=2*2-1;l220>=0;l220--){for(l114=0;l114<4;l114++){l214[l220][l114].l14 = -
99;l214[l220][l114].l15 = -99;l214[l220][l114].l16 = -99;l214[l220][l114].l17
= 0;l214[l220][l114].l18 = 0;l214[l220][l114].l19 = 0;}}return;}static void
l221(l25 l218[]){int16 l114;for(l114=0;l114<4;l114++){l218[l114].l21 = -99;
l218[l114].l22 = -99;l218[l114].l23 = -99;l218[l114].l24 = -99;}return;}int16
l222(int32 l28,l1 l34,int16 l217[],int32 l223[(5000/(60+60)+1)][4]){int16 l84
,l114,l224[4],l111,l225;int16 l226=4,l41,l42,l227,l228[4],l229;uint16 l230;
l84 = 0x0000;for(l114=0;l114<4;l114++){for(l111=0;l111<(5000/(60+60)+1);l111
++)l223[l111][l114] = 0;l224[l114] = 0;l228[l114] = 0;}switch(l28){case
0x00000001:l41 = (int16)0xF8EF;l42 = (int16)0x0400;l230 = 6;break;case
0x00000002:l41 = (int16)0xF8EF;l42 = (int16)0x0100;l230 = 10;break;case
0x00000003:case 0x00000004:case 0x00000005:l41 = (int16)0xF8EF;l42 = (int16)
0x0100;l230 = 10;break;default:l41 = (int16)0xF8EF;l42 = (int16)0x0100;l230 = 
10;l84|= 0x0008;break;}l84|= l38(l34,-1,0,l41,l42);l229 = 0;for(l111=0;l111<(
5000/(60+60)+1);l111++){for(l225=0;l225<75;l225++){for(l114=0;l114<4;l114++){
l84|= l46(l34,0x17,(l114<<13)|0x0002);l84|= l43(l34,0x15,&l227);if(l228[l114]
== 1)continue;l223[l111][l114] = l227;if(((uint16)l227)<= l230)l224[l114]++;
else l224[l114] = 0;if(l224[l114]>l226)l228[l114] = 1;}l229 = 1;for(l114=0;
l114<4;l114++)if(l228[l114] == 0)l229 = 0;if(l229 == 1)break;}if(l229 == 1)
break;}for(l114=0;l114<4;l114++)if(l228[l114] == 0)l217[l114] = 0x0008;return
l84;}static int16 l231(int32 l28,int32 l206[],int16 l5,l1 l34,int16 l40,int16
l230,int16 l232,int16 l39,l20 l214[2*2][4],int16 l217[],int16 l216[],int16*
l233,int16*l234){int16 l84,l190,l235[4],l236;int16 l237[4];int16 l220,l114,
l111,l229,l184;int32*l180,l238;l20*l239;l84 = 0x0000;l190 = 0;if((l39 == 0)&&
(l40 == 0))l238 = l160;else l238 = l161;*l234 = 0;for(l114=0;l114<4;l114++){
l235[l114] = 0;if((l39 == 0)&&(((l217[l114]&0x0008)!= 0)||((l114!= l40)&&((l5
&0x0004) == 0))||(l216[l114]>= 2))){l235[l114] = 1;}else if((l39 == 1)&&(((
l217[l114]&0x0008)!= 0)||((l217[l114]&0x0001)!= 0)||((l217[l114]&0x0002)!= 0)
||((l217[l114]&0x0004)!= 0)||(l216[l114]>= 2))){l235[l114] = 1;}}for(l220=(2-
1);l220>=0;l220--){for(l111=0;l111<(l238+1);l111++){for(l114=l40;l114<4;l114
++){l239 = l214[l220+l232]+l114;l84|= l46(l34,0x17,(l114<<13)|0x0002);l84|= 
l43(l34,0x15,&(l239->l15));l84|= l46(l34,0x17,(l114<<13)|0x0300);l84|= l43(
l34,0x16,&l184);l84|= l46(l34,0x16,l184|0x0002);l84|= l46(l34,0x17,(l114<<13)
|0x0002);l84|= l43(l34,0x15,&(l239->l16));l237[l114] = 0;if(l235[l114] == 1){
}else if(l239->l14 == -99){if((l239->l15<= l230)&&(l239->l16<= l230)){l239->
l14 = 1;l237[l114] = 1;}else{(l239->l17)++;}}else{l237[l114] = 1;}if(l237[
l114] == 0){l84|= l46(l34,0x17,(l114<<13)|0x0300);l84|= l43(l34,0x16,&l184);
l84|= l46(l34,0x16,l184&(~((uint16)0x0002)));}}l229 = 1;for(l114=l40;l114<4;
l114++){l239 = l214[l220+l232]+l114;if((l235[l114] == 0)&&(l239->l14!= 1))
l229 = 0;}if(l229 == 1)break;}l84|= l59(l34,-1,0);for(l114=l40;l114<4;l114++)
{l239 = l214[l220+l232]+l114;l180 = l206+2-1-l216[l114]+l114*2*192;if(l237[
l114] == 1){l84|= l179(l28,l34,l114,l180,&l236);l84|= l46(l34,0x17,(l114<<13)
|0x0300);l84|= l43(l34,0x16,&l184);l84|= l46(l34,0x16,l184&(~((uint16)0x0002)
));l202(l180);if((l236 == 1)||(l114!= l40)){(l239->l19)++;(l216[l114])++;}
else{*l234 = 1;l239->l14 = -99;l239->l15 = -99;l239->l16 = -99;l239->l17 = 0;
l239->l19 = 0;(l239->l18)++;l235[l114] = 1;}}else{l235[l114] = 1;}}if(l220 == 
0){l84|= l189(l34,l190,0);l190 = 0;}else{l84|= l189(l34,l190,l190+64/2);l190 = 
l190+64/2;if(l39 == 0){l84|= l59(l34,-1,0);l84|= l59(l34,l40,1);}else if(l39
== 1){l84|= l59(l34,-1,1);}else{l84|= 0x0002;}sal_usleep(1000*(20));}}*l233 = 
1;for(l114=l40;l114<4;l114++){if(l216[l114]!= 2){l216[l114] = 0;for(l111=0;
l111<2*192;l111++)l206[l114*2*192+l111] = 0;*l233 = 0;}}return l84;}static
int16 l240(int32 l28,int32 l206[],l1 l34,l20 l214[2*2][4]){int16 l84,l236;
int16 l114,l111,l225,l241=3;int32*l180;l20*l239;l84 = 0x0000;for(l225=0;l225<
l241;l225++){for(l114=0;l114<4;l114++){l239 = l214[1+0]+l114;l84|= l46(l34,
0x17,(l114<<13)|0x0002);l84|= l43(l34,0x15,&(l239->l15));(l239->l19)++;l180 = 
l206+2-1+l114*2*192;l84|= l179(l28,l34,l114,l180,&l236);}}for(l114=0;l114<4;
l114++){l180 = l206+2-1+l114*2*192;l239 = l214[1+0]+l114;for(l111=0;l111<192;
l111++){*l180 = ((((int32)*l180)<<8)/l239->l19)>>8;l180+= 2;}l180 = l206+2-1+
l114*2*192;l202(l180);l180 = l206+2-1+l114*2*192;for(l111=0;l111<192;l111++){
*(l180-1) = *l180;l180+= 2;}}return l84;}static int16 l242(int32 l28,int32
l206[],int16 l40){int32 l243,l244;int16 l207,l245;l245 = 32767;l244 = l40*2*
192;for(l207=0;l207<2*192;l207++){if(l206[l207+l244] == 0)continue;switch(l28
){case 0x00000001:if(l207<64*2)l243 = 200000;else l243 = 24000;break;case
0x00000002:if(l207<64*2)l243 = 50000;else l243 = 6000;break;case 0x00000003:
case 0x00000004:case 0x00000005:if(l207<32*2)l243 = 50000;else if(l207<64*2)
l243 = 25000;else if(l207<96*2)l243 = 12000;else if(l207<128*2)l243 = 6000;
else if(l207<160*2)l243 = 2500;else l243 = 2500;break;default:l243 = 50000;
break;}l245 = (int16)(((((int32)l245))<(l243/(((l206[l207+l244])>= 0)?(l206[
l207+l244]):-(l206[l207+l244]))))?(((int32)l245)):(l243/(((l206[l207+l244])>= 
0)?(l206[l207+l244]):-(l206[l207+l244]))));}return(l245);}static int16 l246(
int32 l28,int32 l206[],int16 l5,int16 l40,int16 l217[],int16 l247[],int32 l47
[],int32 l248[],int16 l216[],int16 l249[4][4],int32 l250[],l25 l218[],int16
l251[],int16 l252[]){int16 l207,l253,l254,l114,l255,l256,l257,l111;int16 l84;
int32 l258,l259;int32 l260 = 2;int32 l244;l84 = 0x0000;for(l114=l40;l114<4;
l114++){if((l217[l114]&0x0008)!= 0)continue;if(l216[l114]!= 2){if((l114 == 
l40)||((l5&0x0004)!= 0)){l217[l114] = 0x0008;continue;}}if(l114 == l40){if(
l217[l114] == 0x0001)continue;l255 = 2*4;}else{if((l5&0x0004) == 0)continue;
l255 = 0;}l244 = l114*2*192;for(l207=l255;l207<2*192;l207++){l253 = l207/2;if
(l114 == l40){if(((l206[l207+l244]*l172)>(l251[l253]*l171))||((l206[l207+l244
]*l172)<(-1*l251[l253]*l171))){for(l254=l207+1;l254<2*192;l254++){if((((l206[
l254+l244])>= 0)?(l206[l254+l244]):-(l206[l254+l244]))>(((l206[l207+l244])>= 
0)?(l206[l207+l244]):-(l206[l207+l244])))l207 = l254;}l253 = l207/2;if((l206[
l207+l244]*l172)>(l251[l253]*l171)){l217[l114] = 0x0002;l248[l114] = (((l206[
l207+l244]*10*l172/(l251[l253]*l171))>= 0)?(l206[l207+l244]*10*l172/(l251[
l253]*l171)):-(l206[l207+l244]*10*l172/(l251[l253]*l171)));}else if((l206[
l207+l244]*l172)<(-1*l251[l253]*l171)){l217[l114] = 0x0004;l248[l114] = (((
l206[l207+l244]*10*l172/(l251[l253]*l171))>= 0)?(l206[l207+l244]*10*l172/(
l251[l253]*l171)):-(l206[l207+l244]*10*l172/(l251[l253]*l171)));}else{return
0x0200;}l247[l114] = l207;l47[l114] = l206[l207+l244];break;}}else{l258 = 
l205(0,l206,l114,l207,l260*l162[l253]*l171,l166*l172,2,2,100*2);if((((((l206[
l207+l244])>= 0)?(l206[l207+l244]):-(l206[l207+l244]))*l172*l166)>(l162[l253]
*l171))&&(l258>= 0)){for(l254=l207+1;l254<2*192;l254++){l259 = l205(0,l206,
l114,l254,l260*l162[l254/2]*l171,l166*l172,2,2,100*2);if(((((l206[l254+l244])
>= 0)?(l206[l254+l244]):-(l206[l254+l244]))>(((l206[l207+l244])>= 0)?(l206[
l207+l244]):-(l206[l207+l244])))&&(l259>= 0)){l207 = l254;l258 = l259;}}l253 = 
l207/2;if((l217[l114]!= 0x0001)||(l207<l247[l114])){l217[l114] = 0x0001;l247[
l114] = l207;l47[l114] = l206[l207+l244];l248[l114] = (((l206[l207+l244]*10*
l172*l166/(l162[l253]*l171))>= 0)?(l206[l207+l244]*10*l172*l166/(l162[l253]*
l171)):-(l206[l207+l244]*10*l172*l166/(l162[l253]*l171)));l250[l114] = l258*
10*l172*l166/(l260*(l162[l253]*l171));}if((l217[l40]!= 0x0001)||(l207<l247[
l40])){l217[l40] = 0x0001;l247[l40] = l207;l47[l40] = l206[l207+l244];l248[
l40] = (((l206[l207+l244]*10*l172*l166/(l162[l253]*l171))>= 0)?(l206[l207+
l244]*10*l172*l166/(l162[l253]*l171)):-(l206[l207+l244]*10*l172*l166/(l162[
l253]*l171)));l250[l40] = l258*10*l172*l166/(l260*(l162[l253]*l171));}l249[
l114][l40] = 1;l249[l40][l114] = 1;break;}}}if(((l28 == 0x00000001)||(l28 == 
0x00000002))&&(l247[l114]>2*60)&&(l247[l114]<2*100)){l218[l114].l21 = l247[
l114];l218[l114].l22 = l247[l114];l257 = l247[l114]+3*2;if(l206[l244+l247[
l114]]>= 0){l218[l114].l23 = 1;l218[l114].l24 = 0;}else{l218[l114].l23 = 0;
l218[l114].l24 = 1;}for(l256=0;l256<3*2;l256++){if((((l206[l244+l218[l114].
l21-1])>= 0)?(l206[l244+l218[l114].l21-1]):-(l206[l244+l218[l114].l21-1]))<((
(l206[l244+l218[l114].l22+1])>= 0)?(l206[l244+l218[l114].l22+1]):-(l206[l244+
l218[l114].l22+1]))){l218[l114].l22++;if((l206[l244+l218[l114].l22]*l172)>(
400*l171)){l218[l114].l23++;}else if((l206[l244+l218[l114].l22]*l172)<((-400)
*l171)){l218[l114].l24++;}}else{l218[l114].l21--;if((l206[l244+l218[l114].l21
]*l172)>(400*l171)){l218[l114].l23++;}else if((l206[l244+l218[l114].l21]*l172
)<((-400)*l171)){l218[l114].l24++;}}}for(l111=0;l111<10*2;l111++){if((l206[
l244+l257+l111]*l172)>(400*l171))l218[l114].l24++;else if((l206[l244+l257+
l111]*l172)<((-400)*l171))l218[l114].l23++;}if((l217[l114] == 0x0004)&&(l218[
l114].l23>=(6*2))&&(l218[l114].l23>(l218[l114].l24+4*2))){l217[l114] = 0x0002
;}else if((l217[l114] == 0x0002)&&(l218[l114].l24>=(6*2))&&(l218[l114].l24>(
l218[l114].l23+4*2))){l217[l114] = 0x0004;}}}if(l217[l40] == 0x0000)l252[l40]
= l242(l28,l206,l40);else l252[l40] = 32767;return l84;}static int16 l261(
int32 l28,int32 l206[],int16 l5,l1 l34,int32 l262[],int16 l217[],int16 l247[]
,int32 l47[],int32 l248[],int16 l249[4][4],int32 l250[],int16 l252[]){int16
l84,l40,l216[4],l114,l263,l264;l20 l214[2*2][4];l25 l218[3*4];int32*l204;
int16*l251;l84 = 0x0000;switch(l28){case 0x00000001:l167 = (int16)0xF8AB;l168
= (int16)0x0180;l169 = (int16)0xF8AB;l170 = (int16)0x0080;l171 = 3;l172 = 1;
l251 = (int16*)l163;break;case 0x00000002:l167 = (int16)0xF8AB;l168 = (int16)
0x0100;l169 = (int16)0xF8AB;l170 = (int16)0x0020;l171 = 1;l172 = 1;l251 = (
int16*)l163;break;case 0x00000003:case 0x00000004:case 0x00000005:l167 = (
int16)0xF8AB;l168 = (int16)0x0100;l169 = (int16)0xF8AB;l170 = (int16)0x0100;
l171 = 1;l172 = 2;l251 = (int16*)l162;break;default:l167 = (int16)0xF8AB;l168
= (int16)0x0100;l169 = (int16)0xF8AB;l170 = (int16)0x0020;l171 = 1;l172 = 1;
l251 = (int16*)l163;l84|= 0x0008;break;}for(l40=0;l40<4;l40++){for(l204=l206;
l204<(l206+4*2*192);l204++)*l204 = 0;for(l114=0;l114<4;l114++)l216[l114] = 0;
/* coverity[uninit_use_in_call] */
l219(l214);l221(l218);if((l217[l40]&0x0008)!= 0)continue;l84|= l37(l28,l34);
l84|= l38(l34,0,l40,l167,l168);l84|= l231(l28,l206,l5,l34,l40,0,0,0,l214,l217
,l216,&l263,&l264);if(l263 == 0){if(l28 == 0x00000002)l172 = 1.4;l84|= l37(
l28,l34);l84|= l38(l34,0,l40,l169,l170);l84|= l231(l28,l206,l5,l34,l40,5,2,0,
l214,l217,l216,&l263,&l264);}if(l264 == 1)l84|= 0x0020;l84|= l246(l28,l206,l5
,l40,l217,l247,l47,l248,l216,l249,l250,l218,l251,l252);l213(l206,l214,l262+
l40*((2*2)*4*6+4*4+2*4+4*2*192),l216,l217,l218);}return l84;}static int16 l265
(int32 l28,int32 l206[],int16 l196,int16 l217[],int16 l247[],int32 l47[],
int32 l248[],int32 l266[],int16 l216[],int32 l267[]){int16 l111,l268,l84,l114
;int16 l207,l253,l269,l254;int32 l208;int32 l244;int32 l270,l271,l272[4],l273
,l274;int16 l275[11] = {41,102,274,512,719,802,719,512,274,102,41};l84 = 
0x0000;for(l114=0;l114<4;l114++){if(((l217[l114]&0x0008)!= 0)||((l217[l114]&
0x0001)!= 0)||((l217[l114]&0x0002)!= 0)||((l217[l114]&0x0004)!= 0)){continue;
}else if((l196 == 0)&&(l216[l114]<2)){l217[l114] = 0x0008;}l244 = l114*2*192;
for(l207=2*192-1;l207>=2*4;l207-=1){l266[l114] = (((l206[l207+l244]*l275[5])
>= 0)?(l206[l207+l244]*l275[5]):-(l206[l207+l244]*l275[5]));for(l111=1;l111<=
5;l111++){if((l207-l111)>=0)l266[l114]+= (((l206[l207-l111+l244]*l275[5+l111]
)>= 0)?(l206[l207-l111+l244]*l275[5+l111]):-(l206[l207-l111+l244]*l275[5+l111
]));if((l207+l111)<(2*192))l266[l114]+= (((l206[l207+l111+l244]*l275[5-l111])
>= 0)?(l206[l207+l111+l244]*l275[5-l111]):-(l206[l207+l111+l244]*l275[5-l111]
));}l266[l114] = (l266[l114]+2048)>>12;l273 = (((l206[l207-2+l244]*l275[5])>= 
0)?(l206[l207-2+l244]*l275[5]):-(l206[l207-2+l244]*l275[5]));for(l111=1;l111
<=5;l111++){if((l207-2-l111)>=0)l273+= (((l206[l207-2-l111+l244]*l275[5+l111]
)>= 0)?(l206[l207-2-l111+l244]*l275[5+l111]):-(l206[l207-2-l111+l244]*l275[5+
l111]));if((l207-2+l111)<(2*192))l273+= (((l206[l207-2+l111+l244]*l275[5-l111
])>= 0)?(l206[l207-2+l111+l244]*l275[5-l111]):-(l206[l207-2+l111+l244]*l275[5
-l111]));}l273 = (l273+2048)>>12;l274 = (((l206[l207-3+l244]*l275[5])>= 0)?(
l206[l207-3+l244]*l275[5]):-(l206[l207-3+l244]*l275[5]));for(l111=1;l111<=5;
l111++){if((l207-3-l111)>=0)l274+= (((l206[l207-3-l111+l244]*l275[5+l111])>= 
0)?(l206[l207-3-l111+l244]*l275[5+l111]):-(l206[l207-3-l111+l244]*l275[5+l111
]));if((l207-3+l111)<(2*192))l274+= (((l206[l207-3+l111+l244]*l275[5-l111])>= 
0)?(l206[l207-3+l111+l244]*l275[5-l111]):-(l206[l207-3+l111+l244]*l275[5-l111
]));}l274 = (l274+2048)>>12;l253 = l207/2;if(l196 == 1){l208 = l165[l253];}
else{l208 = l164[l253];}if(((((l266[l114]*l176)>= 0)?(l266[l114]*l176):-(l266
[l114]*l176))>(l208*l175))&&((l253<= 100)||(((((l273)>= 0)?(l273):-(l273))>((
(l266[l114])>= 0)?(l266[l114]):-(l266[l114])))&&((((l274)>= 0)?(l274):-(l274)
)>(((l273)>= 0)?(l273):-(l273)))))){l267[l114] = l207;if((l207<<3)<(2*192)){
l269 = l196?(((2*(4+1))>(l207-2*3))?(2*(4+1)):(l207-2*3)):(((2*(4+1))>(l207-2
*3))?(2*(4+1)):(l207-2*3));}else if((l207<<2)<(2*192)){l269 = l196?(((2*(4+1)
)>(l207-2*5))?(2*(4+1)):(l207-2*5)):(((2*(4+1))>(l207-2*6))?(2*(4+1)):(l207-2
*6));}else if((l207<<1)<(2*192)){l269 = l196?(((2*(4+1))>(l207-2*6))?(2*(4+1)
):(l207-2*6)):(((2*(4+1))>(l207-2*6))?(2*(4+1)):(l207-2*6));}else{l269 = l196
?(((2*(4+1))>(l207-2*6))?(2*(4+1)):(l207-2*6)):(((2*(4+1))>(l207-2*6))?(2*(4+
1)):(l207-2*6));}l271 = l266[l114];for(l254=l207-1;l254>=l269;l254-=1){l272[
l114] = (((l206[l254+l244]*l275[5])>= 0)?(l206[l254+l244]*l275[5]):-(l206[
l254+l244]*l275[5]));for(l268=1;l268<=5;l268++){if((l254-l268)>=0)l272[l114]
+= (((l206[l254-l268+l244]*l275[5+l268])>= 0)?(l206[l254-l268+l244]*l275[5+
l268]):-(l206[l254-l268+l244]*l275[5+l268]));if((l254+l268)<(2*192))l272[l114
]+= (((l206[l254+l268+l244]*l275[5-l268])>= 0)?(l206[l254+l268+l244]*l275[5-
l268]):-(l206[l254+l268+l244]*l275[5-l268]));}l272[l114] = (l272[l114]+2048)
>>12;l270 = l272[l114];if((((l270)>= 0)?(l270):-(l270))>(((l271)>= 0)?(l271):
-(l271))){l207 = l254;l271 = l270;}}l247[l114] = l207;l47[l114] = l271;l208 = 
l196?l165[l207/2]:l164[l207/2];l248[l114] = (((l271*l176*10)>= 0)?(l271*l176*
10):-(l271*l176*10))/(l208*l175);break;}}}return l84;}static int16 l276(int32
l28,int32 l206[],int16 l196,int16 l5,l1 l34,int32 l262[],int16 l217[],int16
l247[],int32 l47[],int32 l248[],int32 l266[],int32 l267[],int16 l252[]){int16
l84,l216[4],l114,l263,l264;l20 l214[2*2][4];l25 l218[4];int32*l204;int16 l277
;l84 = 0x0000;l174 = (int16)0x0800;l277 = (int16)0x7FFF;for(l114=0;l114<4;
l114++){if(l217[l114] == 0x0000)l277 = (((l277)<(l252[l114]))?(l277):(l252[
l114]));}switch(l28){case 0x00000001:if(l277>= 4){l173 = (int16)0xF8DD;l175 = 
(l196)?20:16;}else if(l277 == 3){l173 = (int16)0xF8D2;l175 = (l196)?20:12;}
else if(l277 == 2){l173 = (int16)0xF8C4;l175 = (l196)?20:8;}else{l173 = (
int16)0xF8AB;l175 = (l196)?20:4;}l176 = 9;break;case 0x00000002:if(l277>= 4){
l173 = (int16)0xF8DD;l175 = (l196)?4:4;}else if(l277 == 3){l173 = (int16)
0xF8D2;l175 = (l196)?4:3;}else if(l277 == 2){l173 = (int16)0xF8C4;l175 = (
l196)?4:2;}else{l173 = (int16)0xF8AB;l175 = (l196)?4:1;}l176 = (l196)?2:6;
break;case 0x00000003:case 0x00000004:case 0x00000005:if(l277>= 4){l173 = (
int16)0xF8DD;l175 = (l196)?4:4;}else if(l277 == 3){l173 = (int16)0xF8D2;l175 = 
(l196)?4:3;}else if(l277 == 2){l173 = (int16)0xF8C4;l175 = (l196)?4:2;}else{
l173 = (int16)0xF8AB;l175 = (l196)?4:1;}l176 = (l196)?2:6;break;default:l84|= 
0x0008;break;}if((l28!= 0x00000001)&&(l28!= 0x00000002)){l84|= l46(l34,0x17,
0x0F2B);l84|= l46(l34,0x15,0x0000);}for(l114=0;l114<4;l114++)l216[l114] = 0;
/* coverity[uninit_use_in_call] */
for(l204=l206;l204<(l206+4*2*192);l204++)*l204 = 0;l219(l214);l221(l218);if(
l196 == 0){l84|= l38(l34,1,0,l173,l174);l84|= l231(l28,l206,l5,l34,0,175,0,1,
l214,l217,l216,&l263,&l264);}else{l84|= l240(l28,l206,l34,l214);}l84|= l265(
l28,l206,l196,l217,l247,l47,l248,l266,l216,l267);l213(l206,l214,l262+4*((2*2)
*4*6+4*4+2*4+4*2*192),l216,l217,l218);return l84;}static int16 l278(int32 l28
,int16 l5){if((l5&0x0008)!= 0){if((l28!= 0x00000001)&&(l28!= 0x00000002))
return 1;else return-1;}else{return 0;}}static int16 l279(int16 l5,int16 l7[]
,int16 l8[]){int16 l280 = 80;int16 l281 = 150;if((l7[0] == 0x0002)&&(l8[0]<= 
l280)&&(l7[3] == 0x0002)&&(l8[3]<= l280)){if((l7[1] == 0x0002)&&(l8[1]<= l280
)&&(l8[2]>= l281)){if(l7[2] == 0x0002)return 1;if(l7[2] == 0x0000)return 1;}
if((l7[1] == 0x0002)&&(l8[1]>= l281)&&(l7[2] == 0x0002)&&(l8[2]>= l281)&&((((
l8[1]-l8[2])>= 0)?(l8[1]-l8[2]):-(l8[1]-l8[2]))<= 300)&&((l5&0x0004) == 0)){
return 2;}if((l7[1] == 0x0001)&&(l7[2] == 0x0001)&&((((l8[1]-l8[2])>= 0)?(l8[
1]-l8[2]):-(l8[1]-l8[2]))<= 250)&&((l5&0x0004)!= 0)){return 2;}}return 0;}
static int16 l282(int32 l206[],int16 l5,l1 l34,int16 l7[],int16 l8[],int16*
l82,int16*l283,int32 l262[]){int16 l84,l196;int16 l89,l284;int16 l53,l197[4],
l198[4];int16 l285;int16 l40,l114,l217[4],l247[4],l249[4][4];int32 l248[4],
l266[4],l250[4],l267[4];int32 l223[(5000/(60+60)+1)][4];int16 l252[4];int32
l28;int16 l75[4+1],l76[4+1][4+1],l77[4+1][4+1];int16 l78[4];int32 l79[4];
int16 l286[4],l287[4],l288;int32 l289[4],l74[4],l47[4];int16 l80[4];int16 l73
,l290;l84 = 0x0000;for(l114=0;l114<4;l114++){l247[l114] = 2*192;l248[l114] = 
-99;l266[l114] = -99;for(l40=0;l40<4;l40++)l249[l40][l114] = 0;l250[l114] = -
99;l267[l114] = -99;}l84|= l33(l34,&l28,&l73);l196 = l68(l34);l84|= l195(l196
,l5,l34,l197,l198);l290 = l278(l28,l5);if(l290 == 1){if(l196 == 1){l84|= l70(
(l5&0x0040),(l5&0x0020),l34,l73,l286,l287,l289,l75,l76,l77,l78,l79,l80);l288 = 
0;}else{for(l114=0;l114<4;l114++)l217[l114] = 0x0000;if((l5&0x0010) == 0){l84
|= l37(l28,l34);l84|= l222(l28,l34,l217,l223);}l84|= l81((l5&0x0040),l34,l73,
l286,l287,l289,&l288,l75,l76,l77);}}else if(l290 == 0){if(l196 == 1){for(l114
=0;l114<4;l114++)l217[l114] = 0x0010;l84|= l48(l34,1,&l89);l171 = 1;l172 = 1;
l84|= l276(l28,l206,l196,l5,l34,l262,l217,l247,l47,l248,l266,l267,l252);l84|= 
l46(l34,0x18,l89&0xFFF8);}else{for(l114=0;l114<4;l114++)l217[l114] = 0x0000;
l84|= l37(l28,l34);l84|= l222(l28,l34,l217,l223);l84|= l261(l28,l206,l5,l34,
l262,l217,l247,l47,l248,l249,l250,l252);l84|= l276(l28,l206,l196,l5,l34,l262,
l217,l247,l47,l248,l266,l267,l252);l84|= l46(l34,0x00,(int16)0x8000);l84|= 
l43(l34,0x00,&l284);l84|= l69(l34);}l288 = 0;for(l114=0;l114<4;l114++){l286[
l114] = l217[l114];l285 = l196?-4732:-4732;l287[l114] = (((0)>((((823*l247[
l114])/2+l285)+5)/10))?(0):((((823*l247[l114])/2+l285)+5)/10));for(l40=0;l40<
4;l40++){if(l249[l40][l114] == 1){l288|= (0x1<<(l40*4+l114));l288|= (0x1<<(
l114*4+l40));}}l289[l114] = l47[l114];}}else{l84|= 0x0008;}for(l114=0;l114<4;
l114++){if(l217[l114] == 0x0008){l286[l114] = 0x0008;l287[l114] = -99;l288&= 
0xFFFF^(0x1<<(l40*4+l114));l288&= 0xFFFF^(0x1<<(l114*4+l40));}}*l82 = 0;for(
l114=0;l114<4;l114++){l53 = l197[l114];l7[l53] = l286[l114];l8[l53] = l287[
l114];l74[l53] = l289[l114];for(l40=0;l40<4;l40++){if((0x1<<(l40*4+l114))&
l288){*l82|= (0x1<<(l197[l40]*4+l53));}}}*l283 = l279(l5,l7,l8);return l84;}
int32 l60(l11*l13){l13->l10[0] = (int16)0xF3F0;return 0x0000;}int
phy_5464_cable_diag_sw(int unit,soc_port_t l291,soc_port_cable_diag_t*l6){
int16 l217[4],l292[4];int16 l293,l9;int16 l111;int16 l75;int32*l206;int l294=
0;phy_ctrl_t*l295;l295 = EXT_PHY_SW_STATE(unit,l291);l206 = sal_alloc(sizeof(
*l206)*(4*2*192),"cdiag_taps");if(l206 == NULL){return SOC_E_MEMORY;}l6->
fuzz_len = 0;l6->npairs = 4;l6->state = SOC_PORT_CABLE_STATE_OK;l75 = l282(
l206,0x0004,l295,l217,l292,&l9,&l293,NULL);sal_free(l206);if(l75!= 0x0000){
soc_cm_debug(DK_WARN|DK_VERBOSE,"Cable Diag return code = %d\n",l75);return
SOC_E_FAIL;}for(l111=0;l111<4;l111++){switch(l217[l111]){case 0x0010:l294 = 1
;break;case 0x0000:l6->pair_state[l111] = SOC_PORT_CABLE_STATE_OK;break;case 0x0002
:l6->pair_state[l111] = SOC_PORT_CABLE_STATE_OPEN;break;case 0x0004:l6->
pair_state[l111] = SOC_PORT_CABLE_STATE_SHORT;break;case 0x0001:l6->
pair_state[l111] = SOC_PORT_CABLE_STATE_CROSSTALK;break;case 0x0008:default:
l6->pair_state[l111] = SOC_PORT_CABLE_STATE_UNKNOWN;break;}if(l6->pair_state[
l111]>l6->state){l6->state = l6->pair_state[l111];}l6->pair_len[l111] = ((
l292[l111]+50)/100);}if(l294){return 1;}return SOC_E_NONE;}
#endif /* INCLUDE_PHY_5464 || INCLUDE_PHY_5482 */
